//
//  CategoryModel.swift
//  Employee
//
//  Created by swordjoy on 2017/4/7.
//  Copyright © 2017年 remotevillage. All rights reserved.
//

import Foundation
import SwiftyJSON

// 新建工单 分类
struct CategoryModel: ModelProtocol {
  
  let id: String
  let name: String
  let childrens: [CategoryModel]
  
  init(json: JSON) {
    
    id = json["id"].stringValue
    name = json["name"].stringValue
    
    childrens = CategoryModel.array(from: json["children"].arrayValue)
    
  }
  
  static func array(from jsonArray: [JSON]) -> [CategoryModel] {
    return jsonArray.map({
      return CategoryModel(json: $0)
    })
  }
  
}

